﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary.Data;
using System.Data;
using ClassLibrary.Entity;

namespace ClassLibrary.DAO
{
    public class TblGioithieuDAO
    {
         private DBService _db = null;

        public TblGioithieuDAO(String connectionString)
        {
            _db = new DBService(connectionString);
        }

        public DataTable InGioithieu(string Noidung)
        {
            DataTable flag = null;
            try
            {
                flag = _db.ExeSP_DataTable("insert into TblGioithieu values(@Noidung)",
                    new string[] { "@Noidung" },
                    new object[] { Noidung }, CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return flag;
        }

        public DataTable upGioithieu(string Noidung, int id)
        {
            DataTable flag = null;
            try
            {
                flag = _db.ExeSP_DataTable("update TblGioithieu set Noidung = @Noidung where id = @id",
                    new string[] { "@Noidung", "@id" },
                    new object[] { Noidung, id }, CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return flag;
        }

        public DataTable GetGioithieuByID(int ID)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("select * from TblGioithieu a  where a.id = @ID",
                    new string[] { "@ID" },
                    new object[] { ID },
                    CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }
        public DataTable GetAlll()
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("select * from TblGioithieu", false, CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

    }
}
